$(function(){
    var ckeditor_solution = CKEDITOR.replace("content",{
        filebrowserImageUploadUrl : 'fileUploadController.do?ckeditorUploadImages',
        width : '96%',
        height : '600px',
        toolbar : 'Full',
        toolbarCanCollapse : true,
        resize_enabled : true,
        toolbar_Full : [
            ['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
            ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
            ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
            ['Link','Unlink','Anchor'],
            ['Image','Table','HorizontalRule'],
            '/',
            ['Styles','Format','Font','FontSize'],
            ['TextColor','BGColor']
        ]
    });
    CKEDITOR.on('dialogDefinition', function( ev ){
        var dialogDefinition = ev.data.definition;
        //如果是image对话框
        if (ev.data.name == 'image' ){
            dialogDefinition.removeContents( 'advanced' );
            dialogDefinition.removeContents( 'Link' );
            var ddContents0 = dialogDefinition.contents[0];
            //ddContents0.elements.splice(0,2);//去掉 URL，替换文本
            //隐藏 URL 和 替换文本
            ddContents0.elements[0].hidden = true;
            ddContents0.elements[1].hidden = true;
            var ddContents1 = dialogDefinition.contents[1];
            //调换 上传 和 图像 的位置
            ev.data.definition.contents.splice(0,1,ddContents1);
            ev.data.definition.contents.splice(1,1,ddContents0);
        }
    });
});
